#include <iostream>

using std::cout;
using std::endl;

void test0()
{
    int num = 1, num2 = 2;
    //引用就是一个变量的别名
    //引用一经初始化(绑定)以后，就不会再改变指向
    int & ref = num;

    cout << "&num:" << &num << endl;
    cout << "&ref:" << &ref << endl << endl;

    //给num赋值
    ref = num2;//赋值操作
    cout << "&ref:" << &ref << endl;
    cout << "num:" << num << endl;
    cout << "ref:" << ref << endl;
    cout << "num2:" << num2 << endl;

    //引用是否可以单独存在呢？
    int * p1;
    //int & ref2;//error 引用不可以单独存在
}

int main()
{
    test0();
    return 0;
}

